import * as Apis from "../../apis/Api";
import { observable, action } from 'mobx';
import { message } from 'antd';
class AgreedBillStore {

    @observable refId=-1;
    @observable payType="1";
    @observable payTypeName="收";
    @observable bills = [];
    @observable total = {};

    @action 
    componentWillUnmount = ()=>{
        this.bills = [];
        this.total = {};
    }

    @action
    init = (refId=-1, payType="1") => {
        this.refId = refId;
        this.payType = payType;
        this.payTypeName = payType==="1"?"收":"付";
        const requestParams = {contractId:refId,payType:payType};
        Apis.getAgreedBill(requestParams).then(data => {
            this.bills = data.datas;
            this.total = {proportion:data.proportion,needPay:data.needPay,payTotal:data.payTotal};
        });

    }

    @action 
    sendPays = () =>{
        const requestParams = {contractId:this.refId};
        Apis.sendPays(requestParams).then(data => {
            message.warning(data.datas);
        });
    }
}

export default AgreedBillStore;